<?
    /* -*- Mode: PHP5; tab-width: 4; indent-tabs-mode: nil; basic-offset: 4 -*- */
    
    /*********************************************************
    *            --== itellico Net Architect ==--
    *
    * @author Kulikov Alexey <a.kulikov@gmail.com>
    * @version n/a
    *
    *********************************************************/
    
    /***
    * Abstract Class installNodeInserat
    ****
    * This is the module installer/deinstaller, shall
    * automate integration of new modules into client
    * solutions
    ****
    * @package installNodes
    * @author A Kulikov <a.kulikov@gmail.com>
    * @version n/a
    ***/
    class installNodeShopArticlePackage extends installNode{
        
        /**
         * This is the node install script
         *
         */
        protected function create(){
            
            $this->db->Execute("CREATE TABLE node_shop_package(
                                    id              SERIAL,
                                    
                                    content         TEXT,
                                    teaser          TEXT,
                                    discount        FLOAT DEFAULT 15,
                                    
                                    on_splash       BOOLEAN DEFAULT FALSE,
                                    
                                    created         TIMESTAMP DEFAULT NOW(),
                                    PRIMARY KEY(id)
                                )");                             
            
            $this->db->Execute("CREATE TABLE node_shop_package_article(
                                    article_id      INTEGER,
                                    package_id      INTEGER,
                                    
                                    PRIMARY KEY(article_id, package_id),
                                    FOREIGN KEY(package_id) REFERENCES node_shop_package ON DELETE CASCADE ON UPDATE CASCADE
                                )");                                
        }
        
        
        /**
         * This is the node uninstall script
         *
         */
        protected function remove(){
            //drop database table
            $this->db->Execute("DROP TABLE node_shop_package");
            $this->db->Execute("DROP TABLE node_shop_package_article");
        }
        
        
        /**
         * Sets the properties of this node
         *
         */
        protected function setProps(){
            $this->setDescription('Article Discount Package');
            $this->setAdminAdd(true);
        }
    }
?>